package com.yylending.las.personal.bandcard;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yylending.las.Global;
import com.yylending.las.common.AESEntity;

import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * Created by ying_he on 2017/7/7.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class CardBinModel extends Model {
    @Override
    public Observable getObservable(Object params, int functionalCode) {
        Service service = (Service) NetworkHelper.createService(Service.class);
        return service.getCardBin(Global.LOGIN_TOKEN, (AESEntity) params);
    }

    @Override
    public void onNext(Object entity) {
        CardBinResult result = (CardBinResult) entity;
        EventAgent.post(result);
    }

    public interface Service {
        @POST("server/repay/getBankInfo")
        Observable<CardBinResult> getCardBin(@Header("token") String token, @Body AESEntity requestParams);
    }

    public static class RequestParams{
        public String bankcard;
        public RequestParams(String bankCardNo){
            this.bankcard = bankCardNo;
        }
    }

    public static class CardBinResult extends BaseResultEntity<CardBin>{

    }

    public static class CardBin{
        /**
         * 银行名称
         */
        public String bankName = "";
        /**
         * 银行编号
         */
        String bankNo = "";
    }
}
